package com.hht.kotlineee

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import com.hht.kotlineee.databinding.ActivityMainBinding
import com.hht.kotlineee.databinding.ActivityMainBinding.inflate
import com.hht.kotlineee.viewmodel.MainViewModel

class MainActivity : AppCompatActivity() {

    private lateinit var _binding:ActivityMainBinding
    private lateinit var _mainViewModel:MainViewModel
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        _binding = DataBindingUtil.setContentView(this,R.layout.activity_main)
        _binding.lifecycleOwner = this

        _mainViewModel = ViewModelProvider(this).get(MainViewModel::class.java)
        _binding.model = _mainViewModel
        _binding.btn.also {
            it.setOnClickListener {
                _mainViewModel.getBannerData();
            }
        }
    }
}